{SysSrv} = require "./SysSrv"

SupperClzz = SysSrv
exports.PageAddSrv = new Class
  Extends: SupperClzz
  options:
    tab: "page"
    $vdts: ["code","url"]
  codeVdt: (reqOpt,key,val,id)->
    t = this
    o = t.options
    if val.trim() is ""
      return {err:"编码不能为空!"}
    argArr = []
    sql = "select count(id) count from page where code=$1"
    argArr.push val
    if o.pgType is "edit"
      argArr.push id
      sql += " and id!=$"+argArr.length
    rltSet = yield t.callSql reqOpt,sql,argArr
    rltSet = rltSet.rows
    if rltSet[0].count > 0
      return {err:"编码 "+val+" 已经存在!"}
    true
  urlVdt: (reqOpt,key,val,id)->
    t = this
    o = t.options
    if val.trim() is ""
      return {err:"地址不能为空!"}
    true
